<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CallbackAction
 *
 * @author FERRARI
 */
class Erra_System_CallbackAction extends Erra_System_Action {

    public static function getSelectedObjectList($objectProperties) {
        $fieldList = array();
        foreach ($objectProperties as $selectedField) {
            $object_class = $selectedField['object_class'];
            $object_id = $selectedField['object_id'];
            $currentField = Erra_System_Factory::getFieldObject($object_class, $object_id, 'SQL');
            if (is_object($currentField)) {
                $fieldList[] = $currentField;
            }
        }
        return $fieldList;
    }

    public static function getSelectedObjectProperties($postArray) {
        $objectClass = $postArray['object_class'];
        $checkListId = 'CheckList:' . $objectClass;
        $selectedItems = array();
        if (isset($_POST[$checkListId]) && strlen($_POST[$checkListId])) {
            $checkListData = explode('|', $_POST[$checkListId]);
            foreach ($checkListData as $checkedItem) {
                if (strlen($checkedItem) && strstr($checkedItem, ':')) {
                    $item = explode(':', $checkedItem);
                    if (is_array($item) && count($item) == 4) {
                        $selectedItems[] = array('object_class' => $item[1], 'object_id' => $item[2], 'id' => $item[3]);
                    }
                }
            }
        }
        return $selectedItems;
    }

}

?>
